package com.whfp.coky.db.dbflow;

import android.database.sqlite.SQLiteDatabase;

import androidx.annotation.NonNull;

import com.raizlabs.android.dbflow.config.DatabaseDefinition;
import com.raizlabs.android.dbflow.structure.database.DatabaseHelperListener;
import com.raizlabs.android.dbflow.structure.database.FlowSQLiteOpenHelper;

/**
 * 解决数据库跨版本升级时会丢失字段的问题
 */
public class MyFlowSQliteOpenHelper extends FlowSQLiteOpenHelper {
    public MyFlowSQliteOpenHelper(@NonNull DatabaseDefinition databaseDefinition, @NonNull DatabaseHelperListener listener) {
        super(databaseDefinition, listener);
    }

    @Override
    public void onUpgrade(@NonNull SQLiteDatabase db, int oldVersion, int newVersion) {
//        super.onUpgrade(db, oldVersion, newVersion);
        switch (oldVersion) {
            case 1:
                super.onUpgrade(db, 1, 2);
//                LogUtil.e("数据库版本由1升级到2成功！");
            case 2:
                super.onUpgrade(db, 2, 3);
//                Logger.i("数据库版本由2升级到3成功！");
                break;
        }
    }
}
